package com.miracle.mvpbase

import android.app.Activity
import android.os.Handler
import android.os.SystemClock
import android.provider.Settings
import androidx.core.os.postDelayed
import com.miracle.mvplib.base.BasePresenter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

/**
 * created by miracle on 2022/2/11
 * Desc:
 */
class MainPresenter(view: MainContract.View) : BasePresenter<MainContract.View>(view),
    MainContract.Presenter {

    private val model: MainModel by lazy { MainModel() }

    override fun onCreate() {
        super.onCreate()

    }

    override fun onStart() {
        super.onStart()
        GlobalScope.launch(Dispatchers.Main) {
            var title = ""
            withContext(Dispatchers.IO) {
                SystemClock.sleep(3000)
                title = model.getTitle()

            }

            mView?.setTitleText(title)
        }
    }
}